package kuaidi.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import kuaidi.entity.kuaidijieguo.Kdjg;
import kuaidi.entity.kuaidijieguo.ListBean;
import kuaidi.helper.R;

/**
 * Created by John on 2016/11/1.
 */
public class KdjgAdapter extends RecyclerView.Adapter<KdjgAdapter.ViewHolder>{

    private Context context;
    private Kdjg kdjg;
    private List<ListBean> data;

//    public KdjgAdapter(Context context, Kdjg kdjg) {
//        this.context = context;
//        this.kdjg = kdjg;
//    }


    public KdjgAdapter() {
    }

    public KdjgAdapter(Context context, List<ListBean> data) {
        this.context = context;
        this.data = data;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.item_kdjg_body,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        if (data.size()!=0){
//        holder.itemKdjgDay.setText(kdjg.getResult().getList().get(position).getDatetime().substring(0,10));
//        holder.itemKdjgTime.setText(kdjg.getResult().getList().get(position).getDatetime().substring(10));
//        holder.itemKdjgRemark.setText(kdjg.getResult().getList().get(position).getRemark());
//        holder.itemKdjgZone.setText(kdjg.getResult().getList().get(position).getZone());
            holder.itemKdjgDay.setText(data.get(position).getDatetime().substring(0,10));
            holder.itemKdjgTime.setText(data.get(position).getDatetime().substring(10));
            holder.itemKdjgRemark.setText(data.get(position).getRemark());
            holder.itemKdjgZone.setText(data.get(position).getZone());
        }
    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder{
        @BindView(R.id.item_kdjg_day)
        TextView itemKdjgDay;
        @BindView(R.id.item_kdjg_time)
        TextView itemKdjgTime;
        @BindView(R.id.item_kdjg_zone)
        TextView itemKdjgZone;
        @BindView(R.id.item_kdjg_remark)
        TextView itemKdjgRemark;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
